package com.cwx.mychat.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.cwx.mychat.entity.po.FileCloud;
import com.cwx.mychat.exception.BusinessException;
import com.cwx.mychat.utils.R;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;

/**
 * 作者： cwx
 * 时间： 2025/5/21 16:54
 * 版本： 1.0
 * 注释：
 */
public interface FileCloudService extends IService<FileCloud> {

    /**
     * 查询当前文件夹下面所有文件
     * @param userId
     * @param parentId
     * @return
     */
    R list(String userId, String parentId);

    /**
     * 上传文件
     * @param file
     * @param userId
     * @param parentId
     * @param userName
     * @param fileType
     * @return
     */
    R upload(MultipartFile file, String userId, String parentId, String userName, String fileType, String state) throws BusinessException;

    /**
     * 文件删除
     * @param fileId
     * @return
     */
    R delete(String fileId, String userId) throws BusinessException;

    /**
     * 删除文件夹
     * @param folderId
     * @return
     */
    R deleteFolder(String folderId, String userId) throws BusinessException;

    /**
     * 文件下载
     *
     * @param fileId
     * @param userId
     * @param response
     * @return
     */
    ResponseEntity<InputStreamResource> download(String fileId, String userId, HttpServletResponse response) throws BusinessException;
}
